#ifndef _INPUTFILESTREAM_H
#define	_INPUTFILESTREAM_H

#include "inputstream.h"
#include "buffer.h"
#include <fstream>
#include <string>

#define BUFFERSIZE 256

namespace obj {

    class inputfilestream : public obj::inputstream  {
    public:
        inputfilestream(const std::string& file, unsigned int buffersize = BUFFERSIZE);
        virtual ~inputfilestream();
        virtual char next();
        virtual void restore(char c);
        virtual bool eof();
    private:
        void read();
        
        std::ifstream ifs;
        const unsigned int buffersize;

        obj::buffer readingbuffer;
        obj::buffer restorebuffer;

        char (inputfilestream::*source)();

        char fromReadingBuffer();
        char fromRestoreBuffer();
    };
}

#endif	/* _INPUTFILESTREAM_H */

